import jieba
from wordcloud import WordCloud
from scipy.misc import imread    


def creat_words_cloud(word_base,color_mask_file,res_file_name="wordcloud_anly.png"):
    """
        结果分析
    """

    # 使用jieba分词全部评论
    jiebares = " ".join(jieba.cut(word_base))
    # 提取背景图样式
    color_mask = imread(color_mask_file)
    # 初始化词云配置并生成词云
    # max_words=2000,max_font_size=40,width=1000, height=860, margin=2
    wordcloud = WordCloud(font_path="HYQiHei-25J.ttf",mask=color_mask,background_color="white",max_words=2000,max_font_size=40,width=200, height=160, margin=1).generate(jiebares)
    # 将结果存入文件
    wordcloud.to_file(res_file_name)
